from flask import Blueprint, request
from flask_restful import Api, Resource, marshal_with

from webapp.config.api_utils import oper_log, check_auth
from webapp.dto_mapper import exam_options_page_fields
from webapp.service.exam_service import ExamInfoService

exam_option_app = Blueprint('examoption', __name__, url_prefix='/api/exam/options')
exam_option_api = Api(exam_option_app)

@exam_option_api.resource("", "/")
class CoptionsApi(Resource):
    @oper_log('查询考试添加和编辑时需要的选项', request)
    @check_auth('exam:list', request)
    @marshal_with(exam_options_page_fields)
    def get(self):
        return ExamInfoService.query_all_options()

